//
//  capsuleTableViewController.m
//  PrivateSteward
//
//  Created by 贺银银 on 16/4/2.
//  Copyright © 2016年 闫贺晨. All rights reserved.
//

#import "capsuleTableViewController.h"
#import "CapsuleTableViewCell.h"
#import "typeValue.h"
@interface capsuleTableViewController ()

@end

@implementation capsuleTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
    
    
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CapsuleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"capsule" forIndexPath:indexPath];
    if (indexPath.section <= 1) {
        NSMutableArray *temp = [self imageloading:@"my"];
        cell.capsuleImage.image = [UIImage imageNamed:temp[indexPath.section]];
        cell.capsuleLabel.text = @"自己";
        
    }else if (indexPath.section <= 5&& indexPath.section >= 1){
        NSMutableArray *temp = [self imageloading:@"LOVE"];
        cell.capsuleImage.image = [UIImage imageNamed:temp[indexPath.section - 2]];
        cell.capsuleLabel.text = @"爱情";
        
    }else if (indexPath.section <= 7 && indexPath.section >= 5){
        if (indexPath.section == 6) {
        
            cell.capsuleImage.image = [UIImage imageNamed:@"friend1.png"];
            cell.capsuleLabel.text = @"友情";
            
            
        }else{
            cell.capsuleImage.image = [UIImage imageNamed:@"friend2.png"];
            cell.capsuleLabel.text = @"友情";
        }
        
        NSLog(@"%@",[self imageloading:@"friend"]);
    }else if (indexPath.section == 8){
        cell.capsuleImage.image = [UIImage imageNamed:@"affection1.png"];
      cell.capsuleLabel.text = @"亲情";
    }
    
    
   
    
    return cell;
}


- (NSMutableArray *)imageloading:(NSString *)name{
    NSMutableArray *myArray = [[NSMutableArray alloc] init];
    int a = 0;
    if ([name isEqualToString:@"affctionf"]!= 0) {
        a = 1;
    }else if ([name isEqualToString:@"friend"] != 0){
        a = 2;
    }else if ([name isEqualToString:@"my"] != 0){
        a = 2;
    }else if([name isEqualToString:@"LOVE"] != 0){
        a = 4;
    }
    for (int i = 1; i <= a;  i++) {
        NSString *tempImage = [NSString stringWithFormat:@"%@%d.png",name,i];
        [myArray addObject:tempImage];
    }

    
    return myArray;





}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section
{

    return 0;

}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section{

    return 0;

}

//点击方法
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    typeValue  *type = [typeValue TimeTypeValue];
    

   if (indexPath.section <= 1) {
        type.timeType = @"my";

    }else if (indexPath.section <= 5&& indexPath.section >= 1){
        type.timeType = @"LOVE";
        
    }else if (indexPath.section <= 7 && indexPath.section >= 5){
        
               type.timeType = @"friend";

    }else if (indexPath.section == 8){
   
               type.timeType = @"affection";
    }
   

    NSLog(@"%@",type.timeType);



}







/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
